#pragma once
#include<iostream>
using namespace std;

//用函数指针实现模拟计算器
//加法
double add(double, double);
//减法
double usb(double, double);
//乘法
double mul(double, double);
//除法
double div(double, double);
//打印结果
void print_result(double (*)(double, double), double, double);

double add(double n1, double n2)
{
    return n1 + n2;
}
double sub(double n1, double n2)
{
    return n1 - n2;
}
double mul(double n1, double n2)
{
    return n1 * n2;
}
double div(double n1, double n2)
{
    if(n2==0)
    {
        cout << "除数不可以为'0'哦" << endl;
        return 0;
    }
    return n1 / n2;
}
void print_result(double (*ptrcalc)(double, double), double n1, double n2)
{
    double result = (*ptrcalc)(n1, n2);
    cout << "计算结果是:" << result << endl;
}

